
<template>
  <div>
    <mbao-x item1="数据统计" item2="数据报表"></mbao-x>
    <el-card class="Top">
      <div class="my" ref="MyChar"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import MbaoX from '../components/MbaoX.vue'
export default {
  components: {
    MbaoX
  },
  data() {
    return {
      mychar: [],
      Two: {
        title: {
          text: '用户来源'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#E9EEF3'
            }
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            boundaryGap: false
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ]
      }
    }
  },
  created() {},
  mounted() {
    this.getlist()
  },
  methods: {
    async getlist() {
      const mychar = this.$refs.MyChar
      const one = echarts.init(mychar)
      const res = await this.$http.Chars()
      const options = { ...this.Two, ...res }
      console.log(res)
      //   console.log(one)

      one.setOption(options)
      window.addEventListener('resize', function () {
        echarts.resize()
      })
    }
  }
}
</script>
<style scoped lang='scss'>
.Top {
  margin-top: 20px;
}
.my {
  width: 100%;
  height: 450px;
}
</style>
